package com.cy.pj.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class ServletUtil {

    /**获取请求对象*/
    public static HttpServletRequest getRequest(){
        return getServletRequestAttributes().getRequest();
    }
    /**通过RequestContextHolder类型获取请求属性*/
    public static ServletRequestAttributes getServletRequestAttributes(){//获取ServletRequestAttributes对象，
        return (ServletRequestAttributes)// 然后调用里面的getRequest()方法来获取HttpServletRequest对象，然后通过HttpServletRequest对象，
                //调用里面的getParameter方法，来获取页面的具体信息
                RequestContextHolder.getRequestAttributes();
    }
}
